﻿using UnityEngine;
using System.Collections.Generic;

public class ResourceManager<T> where T : Object
{
    static ResourceManager<T> m_Instance;
    public static ResourceManager<T> Instance
    {
        get
        {
            if (m_Instance == null)
            {
                m_Instance = new ResourceManager<T>();
            }
            return m_Instance;
        }
    }

    Dictionary<string, T> m_ResourceMap = new Dictionary<string, T>();

    public T LoadResource(string path)
    {
        if (!m_ResourceMap.ContainsKey(path))
        {
            T res = Resources.Load<T>(path);
            m_ResourceMap[path] = res;
        }
        return m_ResourceMap[path];
    }
}